<script src="<?=base_url('resources/tools/build/kalendae.js')?>" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="<?=base_url('resources/tools/build/kalendae.css')?>" type="text/css" charset="utf-8">
<script type="text/javascript">
$(document).ready(function(){
	var counter = 60;
	var interval = setInterval(function() {
	    counter--;
	    // Display 'counter' wherever you want to display it.
	    if (counter == 0) {
	        // Display a login box
	        window.location.href="<?=site_url('cart/delivery')?>";
	        clearInterval(interval);
	    }
	}, 1000);					
});

function order_submit(mode){
	
	if(mode=='reservation'){
		$('.delivery_normal .date_arrow').hide();
		var $date = $('#datepicker').val();
		var $time = $('#reservation_time').val();
		var $number = $('.delivery_reservation input[name$="number"]').val();
		var $address= $('.delivery_reservation input[name$="address"]').val();
		var $ring = $('.delivery_reservation input[name$="ring"]').val();
		var $tele = $('.delivery_reservation input[name$="tele"]').val();
		var $date_arrow = $('#date_arrow');
		var $time_arrow = $('#time_arrow');
		var $number_arrow = $('#num_arrow_reservation');
		var $address_arrow = $('#address_arrow_reservation');
		var $ring_arrow = $('#ring_arrow_reservation');
		var $tele_arrow = $('#tele_arrow_reservation');
		if($date !='' && $time !='null' && $number !='' && $address !='' && $ring !='' && $tele !=''){ 
			
			$('#delivery_reservation').submit();
			}else{
				if($date==''){ $date_arrow.show();}else{ $date_arrow.hide(); }
				if($time=='null'){ $time_arrow.show();}else{ $time_arrow.hide(); }
				if($number==''){ $number_arrow.show();}else{ $number_arrow.hide(); }
				if($address==''){ $address_arrow.show();}else{ $address_arrow.hide(); }
				if($ring==''){ $ring_arrow.show();}else{ $ring_arrow.hide(); }
				if($tele==''){ $tele_arrow.show();}else{ $tele_arrow.hide(); }
				
			}
		}else if(mode == 'normal'){
			$('.delivery_reservation .date_arrow').hide();
			var $time = $('#normal_time').val();	
			var $number = $('.delivery_normal input[name$="number"]').val();
			var $address= $('.delivery_normal input[name$="address"]').val();
			var $ring = $('.delivery_normal input[name$="ring"]').val();
			var $tele = $('.delivery_normal input[name$="tele"]').val();
			var $number_arrow = $('#num_arrow_normal');
			var $address_arrow = $('#address_arrow_normal');
			var $ring_arrow = $('#ring_arrow_normal');
			var $tele_arrow = $('#tele_arrow_normal');
			if( $time !='invalid' && $number !='' && $address !='' && $ring !='' && $tele !=''){ 
				
				$('#delivery_normal').submit();
				}else{
					if($time=='invalid'){alert('Notre Magazin sont actuellement fermé, vous pouvez toujours réserver votre commande pour un autre jour, merci beaucoup !'); }
					if($number==''){ $number_arrow.show();}else{ $number_arrow.hide(); }
					if($address==''){ $address_arrow.show();}else{ $address_arrow.hide(); }
					if($ring==''){ $ring_arrow.show();}else{ $ring_arrow.hide(); }
					if($tele==''){ $tele_arrow.show();}else{ $tele_arrow.hide(); }
					
				}
			}
}
</script>
<div class="ctn_delivery">

<div class="delivery_normal" >
<div class="notice">
<p><strong>Veuillez-vous choisir l'heure de livraison, et remplir votre adresse de livraison..</strong></p>
</div>
<br>
<h4>aujourd'hui</h4>
<h3><?=date('d-M-Y')?></h3><br>
<div class="delivery_time">
<form action="<?=site_url('cart/delivery_valid')?>" method="post" id="delivery_normal"> 
<select name="delivery_time" id="normal_time">
<?php if($delivery_shop==2):?>
<?php foreach ($hours as $h):?>
<option <?php if($h->uccle == null){ echo 'disabled';}elseif( time()>=strtotime('-44 minutes',strtotime($h->hour)) )
{echo 'disabled';}?> value="<?=$h->hour?>"><?php if($h->uccle !=null){?><?=$h->hour?><?php }else{ echo '--:--';}?></option>
<?php endforeach;?>
<?php endif;?>
<?php if($delivery_shop==1):?>
<?php foreach ($hours as $h):?>
<option <?php if($h->evere == null){ echo 'disabled';}elseif( time()>=strtotime('-44 minutes',strtotime($h->hour)) )
{echo 'disabled';}?> value="<?=$h->hour?>"><?php if($h->evere !=null){?><?=$h->hour?><?php }else{ echo '--:--';}?></option>
<?php endforeach;?>
<?php endif;?>
<?php if($delivery_shop==3 && date('l') != 'Sunday'):?>
<?php foreach ($hours as $h):?>
<option <?php if($h->etterbeek == null){ echo 'disabled';}elseif( time()>=strtotime('-44 minutes',strtotime($h->hour)) )
{echo 'disabled';}?> value="<?=$h->hour?>"><?php if($h->etterbeek !=null){?><?=$h->hour?><?php }else{ echo '--:--';}?></option>
<?php endforeach;?>
<?php endif;?>
<?php if($delivery_shop==3 && date('l') == 'Sunday'):?>
<?php foreach ($hours as $h):?>
<option <?php if($h->evere == null){ echo 'disabled';}elseif( time()>=strtotime('-44 minutes',strtotime($h->hour)) )
{echo 'disabled';}?> value="<?=$h->hour?>"><?php if($h->evere !=null){?><?=$h->hour?><?php }else{ echo '--:--';}?></option>
<?php endforeach;?>
<?php endif;?>
<option value="invalid">fin de service</option>
</select>
<hr>
<div>
<label>commune</label><?=$post['com_name']?><br>
</div>
<?php if($delivery_address){?>
<div>
<label>numéro de la rue</label><input name="number" value="<?=$delivery_address[0]->house_num?>" type="text"><img class="date_arrow" id="num_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
</div>
<div>
<label>adresse</label><input name="address" value="<?=$delivery_address[0]->address?>" type="text"><img class="date_arrow" id="address_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
</div>
<div>
<label>société ( option )</label><input name="company" value="<?=$delivery_address[0]->company?>" type="text">
</div>
<div>
<label><b>sonette (Veuillez-vous bien vérifier)</b></label><input name="ring" value="<?=$delivery_address[0]->ring?>" type="text"><img class="date_arrow" id="ring_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
</div>
<div>
<label>téléphone</label><input name="tele" value="<?=$delivery_address[0]->tele?>" type="text"><img class="date_arrow" id="tele_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
<br>( example: 0484000000 )
</div>
<?php }else{?>
<div>
<label>numéro de la rue</label><input name="number" value="" type="text"><img class="date_arrow" id="num_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
</div>
<div>
<label>adresse</label><input name="address" value="" type="text"><img class="date_arrow" id="address_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
</div>
<div>
<label>société ( option )</label><input name="company" value=""  type="text">
</div>
<div>
<label>sonette<br> (Veuillez-vous bien vérifier)</label><input name="ring" value="" type="text"><img class="date_arrow" id="ring_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
</div>
<div>
<label>téléphone</label><input name="tele" value="" type="text"><img class="date_arrow" id="tele_arrow_normal" src="<?=base_url()?>resources/imgs/arrow_back_red.png" alt="arrow" title="arrow" width="25">
<br>( example: 0484000000 )
</div>
<?php }?>
<input type="hidden" value="<?=$post['com']?>" name="com_id">
<input type="hidden" value="<?=$post['exrat']?>" name="extra">
<input type="hidden" value="<?=$delivery_shop?>" name="delivery_shop">
<?php if(isset($_POST['discount_type'])){?>
<input type="hidden" value="<?=$post['discount_type']?>" name="discount_type">
<?php }?>
<input type="hidden" value="normal" name="order_type">
<input type="button" value="validez" onclick="order_submit('normal')">
</form>

</div>
</div>

<div class="clear"></div>

</div>